using System;
using System.Web.UI.WebControls;
using THANHTUNGO.Portal.Components.UI;

namespace THANHTUNGO.Portal.Admin
{
    public partial class Roles : PortalModuleControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void odsRoles_Init(object sender, EventArgs e)
        {
            odsRoles.SelectParameters["whereCondition"].DefaultValue = string.Format("PortalID = {0}", this.PortalID);
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                odsRoles.Insert();
            }
        }

        protected void odsRoles_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
        {
            e.InputParameters["Code"] = txtCode.Text.Trim();
            e.InputParameters["Name"] = txtName.Text.Trim();
        }

        protected void odsRoles_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
        {
            txtCode.Text = string.Empty;
            txtName.Text = string.Empty;
            txtCode.Focus();
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string where = string.Format("PortalID = {0}", this.PortalID);
            if (txtCode.Text.Trim().Length > 0) where += string.Format(" AND Code LIKE '{0}'", txtCode.Text);
            if (txtName.Text.Trim().Length > 0) where += string.Format(" AND Name LIKE N'{0}'", txtName.Text);
            odsRoles.SelectParameters["whereCondition"].DefaultValue = where;
        }

        protected void gvRoles_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}